home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / liboctave / QP.h < prev    next >
C/C++ Source or Header  |  1996-03-03  |  3KB  |  122 lines

  1. /*
  2.  
  3. Copyright (C) 1996 John W. Eaton
  4.  
  5. This file is part of Octave.
  6.  
  7. Octave is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2, or (at your option) any
  10. later version.
  11.  
  12. Octave is distributed in the hope that it will be useful, but WITHOUT
  13. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Octave; see the file COPYING.  If not, write to the Free
  19. Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. */
  22.  
  23. #if !defined (octave_QP_h)
  24. #define octave_QP_h 1
  25.  
  26. #include "dMatrix.h"
  27. #include "dColVector.h"
  28. #include "Bounds.h"
  29. #include "LinConst.h"
  30. #include "base-min.h"
  31.  
  32. class
  33. QP : public base_minimizer
  34. {
  35. public:
  36.  
  37.   QP (void)
  38.     : base_minimizer (), H (), c (), bnds (), lc () { }
  39.  
  40.   QP (const ColumnVector& x, const Matrix& H_arg)
  41.     : base_minimizer (x), H (H_arg), c (), bnds (), lc ()
  42.       { make_h_symmetric (); }
  43.  
  44.   QP (const ColumnVector& x, const Matrix& H_arg, const ColumnVector& c_arg)
  45.     : base_minimizer (x), H (H_arg), c (c_arg), bnds (), lc ()
  46.       { make_h_symmetric (); }
  47.  
  48.   QP (const ColumnVector& x, const Matrix& H_arg, const Bounds& b)
  49.     : base_minimizer (x), H (H_arg), c (), bnds (b), lc ()
  50.       { make_h_symmetric (); }
  51.  
  52.   QP (const ColumnVector& x, const Matrix& H_arg, const LinConst& l)
  53.     : base_minimizer (x), H (H_arg), c (), bnds (), lc (l)
  54.       { make_h_symmetric (); }
  55.  
  56.   QP (const ColumnVector& x, const Matrix& H_arg, const ColumnVector& c_arg,
  57.       const Bounds& b)
  58.     : base_minimizer (x), H (H_arg), c (c_arg), bnds (b), lc ()
  59.       { make_h_symmetric (); }
  60.  
  61.   QP (const ColumnVector& x, const Matrix& H_arg, const ColumnVector& c_arg,
  62.       const LinConst& l)
  63.     : base_minimizer (x), H (H_arg), c (c_arg), bnds (), lc (l)
  64.       { make_h_symmetric (); }
  65.  
  66.   QP (const ColumnVector& x, const Matrix& H_arg, const Bounds& b,
  67.       const LinConst& l)
  68.     : base_minimizer (x), H (H_arg), c (), bnds (b), lc (l)
  69.       { make_h_symmetric (); }
  70.  
  71.   QP (const ColumnVector& x, const Matrix& H_arg, const ColumnVector& c_arg,
  72.       const Bounds& b, const LinConst& l)
  73.     : base_minimizer (x), H (H_arg), c (c_arg), bnds (b), lc (l)
  74.       { make_h_symmetric (); }
  75.  
  76.   QP (const QP& qp)
  77.     : base_minimizer (qp), H (qp.H), c (qp.c), bnds (qp.bnds), lc (qp.lc) { }
  78.  
  79.   QP& operator = (const QP& qp)
  80.     {
  81.       if (this != &qp)
  82.     {
  83.       base_minimizer::operator = (qp);
  84.  
  85.       H = qp.H;
  86.       c = qp.c;
  87.       bnds = qp.bnds;
  88.       lc = qp.lc;
  89.     }
  90.       return *this;
  91.     }
  92.  
  93.   virtual ~QP (void) { }
  94.  
  95.   Matrix hessian (void) const { return H; }
  96.  
  97.   ColumnVector linear_obj_coeff (void) const { return c; }
  98.  
  99.   Bounds bounds (void) const { return bnds; }
  100.  
  101.   LinConst linear_constraints (void) const { return lc; }
  102.  
  103. protected:
  104.  
  105.   Matrix H;  
  106.   ColumnVector c;
  107.   Bounds bnds;
  108.   LinConst lc;
  109.  
  110. private:
  111.  
  112.   Matrix make_h_symmetric (void) { return 0.5 * (H + H.transpose ()); }
  113. };
  114.  
  115. #endif
  116.  
  117. /*
  118. ;;; Local Variables: ***
  119. ;;; mode: C++ ***
  120. ;;; End: ***
  121. */
  122.